import { createApp } from 'vue'
import App from './App.vue'
import router from './router'

import 'font-awesome/css/font-awesome.min.css'
import axios from 'axios';
import { stringifyQuery } from 'vue-router';
//导入element-plus框架
import ElementPlus from 'element-plus'
import 'element-plus/theme-chalk/index.css'

axios.defaults.baseURL = "http://localhost:8080/tijian/";

//使用路由守卫实现登录的权限验证
router.beforeEach(function(to,from,next){
    let token = localStorage.getItem('token');
    let users = sessionStorage.getItem("users");
    
    // 除了登录、注册之外，都需要判断是否登录
    if(!(to.path=='/'||to.path=='/login'||to.path=='/register')){
        if(users == null){
            router.push("/login")
        }
    }
    next();
});

// createApp(App).use(router).mount('#app')
const app = createApp(App);  
  
app.use(router); // 如果你有路由配置  
app.use(ElementPlus); // 使用Element Plus  
  
app.mount('#app');